<?php

/* 视频举报 */
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\facade\Db;

class VideoreportController extends AdminBaseController
{
 
    public function index()
    {
        
        $data = $this->request->param();
        $map=[];
        $status=isset($data['status']) ? $data['status']: '';
        if($status!=''){
            $map[]=['status','=',$status];
        }

        $start_time=isset($data['start_time']) ? $data['start_time']: '';
        $end_time=isset($data['end_time']) ? $data['end_time']: '';
        if($start_time!=""){
           $map[]=['addtime','>=',strtotime($start_time)];
        }
        if($end_time!=""){
           $map[]=['addtime','<=',strtotime($end_time) + 60*60*24];
        }

        $uid=isset($data['uid']) ? $data['uid']: '';
        if($uid!=''){
            $map[]=['uid','=',$uid];
        }
		
		$videoid=isset($data['videoid']) ? $data['videoid']: '';
        if($videoid!=''){
            $map[]=['videoid','=',$videoid];
        }
		
		$touid=isset($data['touid']) ? $data['touid']: '';
        if($touid!=''){
            $map[]=['touid','=',$touid];
        }

        
        $list = Db::name('video_report')
            ->where($map)
            ->order("id desc")
            ->paginate(20);
        $list->each(function($v,$k){
           $v['userinfo']= getUserInfo($v['uid']);
           $v['tuserinfo']= getUserInfo($v['touid']);
           return $v; 
        });
        $list->appends($data);
        
        $page = $list->render();
        $this->assign("page", $page);
            
        $this->assign('list', $list);

        return $this->fetch();
    }


    public function setStatus()
    {
        $id = $this->request->param('id', 0, 'intval');
        
        if(!$id){
            $this->error("数据传入失败！");
        }
        
        $result=Db::name("video_report")->where("id={$id}")->find();				
        if($result){

            Db::name("video_report")->where("id='{$result['id']}'")->update(array("status"=>1,"uptime"=>time()));
                

            $this->success('操作成功');
         }else{
            $this->error('数据传入失败！');
         }	
             
    }


}